package com.richard.springcloud.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.richard.cloud.entity.Payment;
import com.richard.springcloud.base.ComnResult;
import com.richard.springcloud.service.PaymentService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
public class PaymentController {
	@Resource
	private PaymentService paymentService;
	
	@PostMapping("/payment")
	public ComnResult create(Payment payment) {
		boolean save = paymentService.save(payment);
		log.info("数据插入结果：{}", save);
		if(save) {
			return new ComnResult<>(200, "数据插入成功", payment, true);
		}else {
			return new ComnResult<>(444, "数据插入失败");
		}
	}
	
	@GetMapping("/payment/{id}")
	public ComnResult<Payment> get(@PathVariable Long id) {
		Payment byId = paymentService.getById(id);
		return new ComnResult<>(200, null, byId, true);
	}
}
